<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="theme-color" content="#0d6efd">
    <title>星脉新闻平台</title>
    
    <!-- EmailJS SDK -->
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@emailjs/browser@3/dist/email.min.js"></script>
    <script type="text/javascript">
        (function() {
            // 初始化 EmailJS
            emailjs.init('DnSeHouzFWQnIQKoT');
        })();
    </script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    
    <!-- 自定义样式 -->
    <link rel="stylesheet" href="styles.css">
    <style>
        /* 添加链接样式 */
        .message-content a {
            color: #0d6efd;
            text-decoration: none;
            word-break: break-all;
        }
        
        .message-content a:hover {
            text-decoration: underline;
        }
        
        /* 搜索结果样式 */
        .search-result {
            background-color: #f8f9fa;
            border-left: 3px solid #0d6efd;
            padding: 10px;
            margin: 10px 0;
            border-radius: 0 4px 4px 0;
        }
        
        .search-result .title {
            font-weight: bold;
            margin-bottom: 5px;
        }
        
        .search-result .url {
            color: #6c757d;
            font-size: 0.85em;
            margin-bottom: 5px;
            display: block;
        }
        
        .search-result .snippet {
            font-size: 0.9em;
            color: #333;
        }
    </style>
</head>
<body>
    <!-- 顶部导航 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="#">星脉新闻平台</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link active" href="#">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#categories">新闻类别</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#recommendations">推荐新闻</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#usage-guide">使用指南</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 主体内容 -->
    <main>
        <!-- 首页轮播图 -->
        <div id="home" class="carousel slide" data-bs-ride="carousel">
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src="assets/images/banner.jpg" class="d-block w-100" alt="星脉新闻平台" style="height: 400px; object-fit: cover;">
                    <div class="carousel-caption">
                        <h2>欢迎使用星脉新闻平台</h2>
                        <p>获取最新、最全面的新闻资讯</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- 搜索框 -->
        <div class="container py-5">
            <div class="row justify-content-center">
                <div class="col-md-8">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title text-center mb-4">新闻搜索</h5>
                            <form id="newsSearchForm">
                                <div class="mb-3">
                                    <label for="categoryInput" class="form-label"></label>
                                    <input type="text" class="form-control" id="categoryInput" placeholder="请输入您感兴趣的内容">
                                </div>
                                <button type="submit" class="btn btn-primary w-100">搜索新闻</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        
        <!-- 浏览历史 -->
        <section id="browse-history" class="py-3">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-md-10">
                        <div class="card shadow-sm">
                            <div class="card-header bg-light d-flex justify-content-between align-items-center">
                                <h6 class="mb-0">
                                    <i class="fas fa-history me-2"></i>最近浏览
                                </h6>
                                <button id="clearHistoryBtn" class="btn btn-sm btn-outline-secondary">
                                    <i class="fas fa-trash-alt me-1"></i>清除
                                </button>
                            </div>
                            <div class="card-body p-2">
                                <div id="historyList">
                                    <p class="text-muted small mb-0">您的浏览记录将显示在这里</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        
        <!-- 新闻类别选择 -->
        <div class="container py-5">
            <h2 class="text-center mb-5">新闻类别</h2>
            <div class="row">
                <div class="col-12">
                    <div class="d-flex justify-content-center gap-3">
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-motherboard-fill text-white"></i>
                                </div>
                                <h5 class="category-title">科技新闻</h5>
                                <p class="category-text">最新科技动态和资讯</p>
                                <a href="#" class="btn btn-light category-link" data-category="科技">查看科技新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-bicycle text-white"></i>
                                </div>
                                <h5 class="category-title">体育新闻</h5>
                                <p class="category-text">最新体育赛事和资讯</p>
                                <a href="#" class="btn btn-light category-link" data-category="体育">查看体育新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-globe2 text-white"></i>
                                </div>
                                <h5 class="category-title">国际新闻</h5>
                                <p class="category-text">全球最新国际资讯</p>
                                <a href="#" class="btn btn-light category-link" data-category="国际">查看国际新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-music-note text-white"></i>
                                </div>
                                <h5 class="category-title">娱乐新闻</h5>
                                <p class="category-text">最新娱乐资讯和明星动态</p>
                                <a href="#" class="btn btn-light category-link" data-category="娱乐">查看娱乐新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-book text-white"></i>
                                </div>
                                <h5 class="category-title">教育新闻</h5>
                                <p class="category-text">教育政策与学习资源</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E6%95%99%E8%82%B2" target="_blank" class="btn btn-light category-link" data-category="教育">查看教育新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-airplane text-white"></i>
                                </div>
                                <h5 class="category-title">旅游新闻</h5>
                                <p class="category-text">旅行攻略与景点推荐</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E6%97%85%E6%B8%B8" target="_blank" class="btn btn-light category-link" data-category="旅游">查看旅游新闻</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row mt-4">
                <div class="col-12">
                    <div class="d-flex justify-content-center gap-3 flex-wrap">
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-egg-fried text-white"></i>
                                </div>
                                <h5 class="category-title">美食新闻</h5>
                                <p class="category-text">美食文化与食谱分享</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E7%BE%8E%E9%A3%9F" target="_blank" class="btn btn-light category-link" data-category="美食">查看美食新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-car-front-fill text-white"></i>
                                </div>
                                <h5 class="category-title">汽车新闻</h5>
                                <p class="category-text">汽车资讯与评测</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E6%B1%BD%E8%BD%A6" target="_blank" class="btn btn-light category-link" data-category="汽车">查看汽车新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-bag-heart text-white"></i>
                                </div>
                                <h5 class="category-title">时尚新闻</h5>
                                <p class="category-text">潮流趋势与穿搭指南</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E6%97%B6%E5%B0%9A" target="_blank" class="btn btn-light category-link" data-category="时尚">查看时尚新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-joystick text-white"></i>
                                </div>
                                <h5 class="category-title">游戏新闻</h5>
                                <p class="category-text">游戏资讯与攻略</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E6%B8%B8%E6%88%8F" target="_blank" class="btn btn-light category-link" data-category="游戏">查看游戏新闻</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row mt-4">
                <div class="col-12">
                    <div class="d-flex justify-content-center gap-3 flex-wrap">
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-currency-exchange text-white"></i>
                                </div>
                                <h5 class="category-title">财经新闻</h5>
                                <p class="category-text">财经动态与市场分析</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E8%B4%A2%E7%BB%8F" target="_blank" class="btn btn-light category-link" data-category="财经">查看财经新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-shield-check text-white"></i>
                                </div>
                                <h5 class="category-title">军事新闻</h5>
                                <p class="category-text">国防动态与军事科技</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E5%86%9B%E4%BA%8B" target="_blank" class="btn btn-light category-link" data-category="军事">查看军事新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-brush text-white"></i>
                                </div>
                                <h5 class="category-title">文化新闻</h5>
                                <p class="category-text">文化艺术与人文历史</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E6%96%87%E5%8C%96" target="_blank" class="btn btn-light category-link" data-category="文化">查看文化新闻</a>
                            </div>
                        </div>
                        <div class="category-card">
                            <div class="category-card-content text-center">
                                <div class="category-icon">
                                    <i class="bi bi-tree text-white"></i>
                                </div>
                                <h5 class="category-title">环境新闻</h5>
                                <p class="category-text">环保资讯与可持续发展</p>
                                <a href="https://www.baidu.com/s?rtt=1&bsst=1&cl=2&tn=news&rsv_dl=ns_pc&word=%E6%96%B0%E9%97%BB%20%E7%8E%AF%E5%A2%83" target="_blank" class="btn btn-light category-link" data-category="环境">查看环境新闻</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 用户指南 -->
        <section id="usage-guide" class="py-5">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-md-10">
                        <div class="card shadow">
                            <div class="card-body text-center">
                                <h2 class="mb-4">使用指南</h2>
                                <button class="btn btn-lg btn-outline-primary rounded-pill" id="showGuide" data-bs-toggle="modal" data-bs-target="#usageModal">
                                    <i class="bi bi-info-circle me-2"></i>查看使用指南
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- 使用指南模态框 -->
        <div class="modal fade" id="usageModal" tabindex="-1">
            <div class="modal-dialog modal-xl">
                <div class="modal-content rounded-4">
                    <div class="modal-header bg-primary text-white">
                        <h5 class="modal-title text-white">新闻平台使用指南</h5>
                        <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
                    </div>
                    <div class="modal-body p-5">
                        <div class="container">
                            <div class="row justify-content-center">
                                <div class="col-md-10">
                                    <div class="card shadow">
                                        <div class="card-body p-4">
                                            <h3 class="text-primary mb-5">如何使用新闻平台</h3>
                                            <div class="accordion accordion-flush" id="guideAccordion">
                                                <div class="accordion-item">
                                                    <h2 class="accordion-header">
                                                        <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#guide1">
                                                            <span class="h5 mb-0">1. 如何搜索新闻</span>
                                                        </button>
                                                    </h2>
                                                    <div id="guide1" class="accordion-collapse collapse show">
                                                        <div class="accordion-body">
                                                            <ol class="list-unstyled">
                                                                <li class="mb-3">
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    在首页顶部的搜索框中输入您感兴趣的新闻类别（如：科技、体育、娱乐等）
                                                                </li>
                                                                <li class="mb-3">
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    点击"搜索新闻"按钮或按回车键，系统将自动跳转到百度新闻搜索结果
                                                                </li>
                                                                <li>
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    您可以在百度新闻页面查看相关新闻
                                                                </li>
                                                            </ol>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="accordion-item">
                                                    <h2 class="accordion-header">
                                                        <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#guide2">
                                                            <span class="h5 mb-0">2. 如何查看推荐新闻</span>
                                                        </button>
                                                    </h2>
                                                    <div id="guide2" class="accordion-collapse collapse">
                                                        <div class="accordion-body">
                                                            <ol class="list-unstyled">
                                                                <li class="mb-3">
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    在首页下方可以看到推荐的新闻类别卡片
                                                                </li>
                                                                <li class="mb-3">
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    点击感兴趣的新闻类别卡片，可以直接查看该类别的新闻
                                                                </li>
                                                                <li>
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    每个推荐新闻都链接到百度百家号的具体文章
                                                                </li>
                                                            </ol>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="accordion-item">
                                                    <h2 class="accordion-header">
                                                        <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#guide3">
                                                            <span class="h5 mb-0">3. 如何使用AI新闻助手</span>
                                                        </button>
                                                    </h2>
                                                    <div id="guide3" class="accordion-collapse collapse" data-bs-parent="#guideAccordion">
                                                        <div class="accordion-body">
                                                            <p>我们提供了AI新闻助手功能，可以帮您：</p>
                                                            <ul>
                                                                <li>在联系我们下方可以找到AI新闻助手</li>
                                                                <li>询问任何与新闻相关的问题</li>
                                                                <li>获取新闻内容的详细分析</li>
                                                                <li>获取使用帮助</li>
                                                            </ul>
                                                            <p class="mb-0">AI助手24小时在线，随时为您服务！</p>
                                                        </div>
                                                    </div>
                                                </div>
                                                
                                                <div class="accordion-item">
                                                    <h2 class="accordion-header">
                                                        <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#guide4-history">
                                                            <span class="h5 mb-0">4. 如何使用浏览历史</span>
                                                        </button>
                                                    </h2>
                                                    <div id="guide4-history" class="accordion-collapse collapse" data-bs-parent="#guideAccordion">
                                                        <div class="accordion-body">
                                                            <p class="mb-3">在搜索框下方可以看到您的浏览历史记录：</p>
                                                            <ol class="list-unstyled">
                                                                <li class="mb-3">
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    您浏览过的新闻类别会自动保存在浏览历史中
                                                                </li>
                                                                <li class="mb-3">
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    点击历史记录中的类别名称可以快速访问该类别新闻
                                                                </li>
                                                                <li class="mb-3">
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    点击右上角的<i class="fas fa-times text-muted mx-1"></i>按钮可以删除单条历史记录
                                                                </li>
                                                                <li>
                                                                    <i class="bi bi-check-circle text-primary me-2"></i>
                                                                    点击"清除"按钮可以清空所有浏览历史
                                                                </li>
                                                            </ol>
                                                            <p class="text-muted small mt-3 mb-0">提示：浏览历史仅保存在您的浏览器中，不会上传到服务器</p>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="accordion-item">
                                                    <h2 class="accordion-header">
                                                        <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#guide5-notice">
                                                            <span class="h5 mb-0">5. 注意事项</span>
                                                        </button>
                                                    </h2>
                                                    <div id="guide5-notice" class="accordion-collapse collapse" data-bs-parent="#guideAccordion">
                                                        <div class="accordion-body">
                                                            <ul class="list-unstyled">
                                                                <li class="mb-3">
                                                                    <i class="bi bi-exclamation-triangle-fill text-warning me-2"></i>
                                                                    请勿在公共电脑上保存个人登录信息
                                                                </li>
                                                                <li class="mb-3">
                                                                    <i class="bi bi-exclamation-triangle-fill text-warning me-2"></i>
                                                                    请勿点击来源不明的链接
                                                                </li>
                                                                <li class="mb-3">
                                                                    <i class="bi bi-exclamation-triangle-fill text-warning me-2"></i>
                                                                    如发现异常情况，请及时联系管理员
                                                                </li>
                                                                <li>
                                                                    <i class="bi bi-exclamation-triangle-fill text-warning me-2"></i>
                                                                    建议定期清除浏览记录和缓存
                                                                </li>
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        

        <!-- 推荐新闻 -->
        <section id="recommendations" class="py-5 bg-light">
            <div class="container">
                <h2 class="text-center mb-5">推荐新闻</h2>
                <div class="row" id="recommendation-list">
                    <!-- 推荐新闻卡片 -->
                    <div class="col-md-4 mb-4">
                        <div class="card h-100">
                            <img src="assets/images/2.png" class="card-img-top" alt="科技新闻" style="height: 200px; object-fit: cover;">
                            <div class="card-body">
                                <h5 class="card-title">科技新闻</h5>
                                <p class="card-text">最新科技动态，掌握科技前沿</p>
                                <a href="https://baijiahao.baidu.com/s?id=1832730309741010532&wfr=spider&for=pc" class="btn btn-primary" target="_blank">查看详情</a>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4 mb-4">
                        <div class="card h-100">
                            <img src="assets/images/1.png" class="card-img-top" alt="体育新闻" style="height: 200px; object-fit: cover;">
                            <div class="card-body">
                                <h5 class="card-title">体育新闻</h5>
                                <p class="card-text">最新体育赛事，精彩不容错过</p>
                                <div class="d-flex justify-content-between">
                                    <a href="https://baijiahao.baidu.com/s?id=1832610197338702215&wfr=spider&for=pc" class="btn btn-primary" target="_blank">查看详情</a>
                                    <button class="btn btn-outline-secondary copy-news" data-title="体育新闻" data-content="最新体育赛事，精彩不容错过">
                                        <i class="bi bi-clipboard"></i> 复制内容
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4 mb-4">
                        <div class="card h-100">
                            <img src="assets/images/3.png" class="card-img-top" alt="娱乐新闻" style="height: 200px; object-fit: cover;">
                            <div class="card-body">
                                <h5 class="card-title">娱乐新闻</h5>
                                <p class="card-text">娱乐八卦，明星动态</p>
                                <div class="d-flex justify-content-between">
                                    <a href="https://baijiahao.baidu.com/s?id=1832519326449982997&wfr=spider&for=pc" class="btn btn-primary" target="_blank">查看详情</a>
                                    <button class="btn btn-outline-secondary copy-news" data-title="娱乐新闻" data-content="娱乐八卦，明星动态">
                                        <i class="bi bi-clipboard"></i> 复制内容
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>



        <!-- 联系我们 -->
        <section id="contact" class="py-5 bg-light">
            <div class="container">
                <h2 class="text-center mb-5">联系我们</h2>
                <div class="row">
                    <div class="col-md-6 mx-auto">
                        <form>
                            <div class="mb-3">
                                <label for="name" class="form-label">姓名</label>
                                <input type="text" class="form-control" id="name">
                            </div>
                            <div class="mb-3">
                                <label for="email" class="form-label">邮箱</label>
                                <input type="email" class="form-control" id="email">
                            </div>
                            <div class="mb-3">
                                <label for="message" class="form-label">消息</label>
                                <textarea class="form-control" id="message" rows="5"></textarea>
                            </div>
                            <button type="submit" class="btn btn-primary">发送</button>
                        </form>
                    </div>
                </div>
            </div>
        </section>
        <!-- AI 新闻助手 -->
        <section id="ai-assistant" class="py-5 bg-light">
            <div class="container">
                <h2 class="text-center mb-5">AI 新闻助手</h2>
                <div class="row justify-content-center">
                    <div class="col-lg-8">
                        <div class="card shadow-sm">
                            <div class="card-header bg-primary text-white">
                                <span><i class="fas fa-robot me-2"></i>智能助手</span>
                                <button id="clearChatBtn" class="btn btn-sm btn-outline-light float-end">
                                    <i class="fas fa-trash-alt me-1"></i>清空对话
                                </button>
                            </div>
                            <div class="card-body p-0">
                                <div id="chat-messages" class="p-3" style="height: 400px; overflow-y: auto;">
                                    <div class="text-center text-muted py-5">
                                        <i class="fas fa-comments fa-3x mb-3"></i>
                                        <p>我是您的AI新闻助手，请问有什么可以帮您？</p>
                                    </div>
                                </div>
                                <div class="card-footer bg-white border-top">
                                    <form id="chat-form" class="d-flex">
                                        <input type="text" id="user-input" class="form-control me-2" 
                                               placeholder="输入您的问题..." required>
                                        <button type="submit" class="btn btn-primary">
                                            <span id="send-text">发送</span>
                                            <span id="sending-text" class="d-none">
                                                <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                                                发送中...
                                            </span>
                                        </button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- 新闻模态框 -->
    <div class="modal fade" id="newsModal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">新闻列表</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div class="news-list"></div>
                </div>
            </div>
        </div>
    </div>

    <!-- 底部 -->
    <footer class="bg-dark text-light py-4">
        <div class="container">
            <div class="row">
                <div class="col-md-4">
                    <h5>关于我们</h5>
                    <p>提供最新、最全面的新闻资讯</p>
                </div>
                <div class="col-md-4">
                    <h5>联系我们</h5>
                    <p>邮箱：1545723153@qq.com</p>
                </div>
                <div class="col-md-4">
                    <h5>关注我们</h5>
                    <div class="social-links">
                        <a href="#"><i class="fab fa-weibo"></i></a>
                        <a href="#"><i class="fab fa-wechat"></i></a>
                        <a href="#"><i class="fab fa-qq"></i></a>
                    </div>
                    <h5>联系方式</h5>
                    <p>
                        <i class="bi bi-telephone"></i> 电话: 13335311080<br>
                        <i class="bi bi-envelope"></i> 邮箱: 1545723153@qq.com<br>
                        <i class="bi bi-geo-alt"></i> 地址: 榆林学院2S实验楼413
                    </p>
                </div>
            </div>
            <hr>
            <div class="text-center">
                <p>&copy; 2025 星脉算法. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <!-- 配置文件 -->
    <script src="config.js"></script>
    
    <!-- 新闻API脚本 -->
    <script src="news-api.js"></script>
    
    <!-- 自定义脚本 -->
    <script src="script.js"></script>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // 历史记录相关函数
        const HISTORY_KEY = 'news_history';

        // 获取历史记录
        const getHistory = () => {
            const history = localStorage.getItem(HISTORY_KEY);
            return history ? JSON.parse(history) : [];
        };

        // 保存历史记录
        const saveHistory = (history) => {
            localStorage.setItem(HISTORY_KEY, JSON.stringify(history));
        };

        // 添加历史记录
        const addHistory = (category) => {
            const history = getHistory();
            const updatedHistory = [...new Set([...history, category])];
            saveHistory(updatedHistory);
            updateHistoryDisplay();
        };

        // 更新历史记录显示
        const updateHistoryDisplay = () => {
            const historyList = document.querySelector('.history-list');
            const history = getHistory();
            
            if (history.length === 0) {
                historyList.innerHTML = '<p class="text-muted">暂无历史记录</p>';
                return;
            }

            historyList.innerHTML = history.map(category => `
                <div class="card mb-3">
                    <div class="card-body">
                        <h5 class="card-title">${category}</h5>
                        <p class="card-text">最近查看时间: ${new Date().toLocaleDateString()}</p>
                        <div class="d-flex justify-content-between align-items-center">
                            <a href="https://news.baidu.com/ns?word=${encodeURIComponent(`新闻 ${category}`)}&tn=newssearch" class="btn btn-primary btn-sm">再次查看</a>
                            <button class="btn btn-outline-danger btn-sm" onclick="removeHistory('${category}')">删除</button>
                        </div>
                    </div>
                </div>
            `).join('');
        };

        // 删除指定历史记录
        const removeHistory = (category) => {
            const history = getHistory();
            const updatedHistory = history.filter(c => c !== category);
            saveHistory(updatedHistory);
            updateHistoryDisplay();
        };

        // 清除所有历史记录
        const clearAllHistory = () => {
            if (confirm('确定要清除所有历史记录吗？')) {
                localStorage.removeItem(HISTORY_KEY);
                updateHistoryDisplay();
            }
        };

        // 初始化搜索功能
        const initSearchFunctionality = () => {
            const searchForm = document.getElementById('newsSearchForm');
            if (searchForm) {
                searchForm.addEventListener('submit', (e) => {
                    e.preventDefault();
                    
                    const category = document.getElementById('categoryInput').value.trim();
                    
                    // 验证输入
                    if (!category) {
                        alert('请输入新闻类别');
                        return;
                    }

                    // 添加到历史记录
                    addHistory(category);

                    // 构建百度新闻搜索URL
                    const baiduSearchUrl = `https://news.baidu.com/ns?word=${encodeURIComponent(`新闻 ${category}`)}&tn=newssearch`;
                    
                    // 直接跳转到百度新闻搜索
                    window.location.href = baiduSearchUrl;
                });
            }
        };

        // 初始化新闻类别点击事件
        const initCategoryClicks = () => {
            const categoryLinks = document.querySelectorAll('.category-link');
            categoryLinks.forEach(link => {
                link.addEventListener('click', (e) => {
                    e.preventDefault();
                    const category = e.target.dataset.category;
                    addHistory(category);
                    window.location.href = `https://news.baidu.com/ns?word=${encodeURIComponent(`新闻 ${category}`)}&tn=newssearch`;
                });
            });
        };

        // 初始化所有功能
        document.addEventListener('DOMContentLoaded', () => {
            initSearchFunctionality();
            initCategoryClicks();
            initClearHistory();
            updateHistoryDisplay();
        });

        // 初始化清除历史按钮
        const initClearHistory = () => {
            const clearButton = document.getElementById('clearHistory');
            if (clearButton) {
                clearButton.addEventListener('click', clearAllHistory);
            }
        };

        // 初始化所有功能
        document.addEventListener('DOMContentLoaded', () => {
            // 初始化搜索功能
            const searchForm = document.getElementById('newsSearchForm');
            if (searchForm) {
                searchForm.addEventListener('submit', (e) => {
                    e.preventDefault();
                    const query = document.getElementById('categoryInput').value.trim();
                    if (query) {
                        window.location.href = `https://news.baidu.com/ns?word=${encodeURIComponent(query)}`;
                    }
                });
            }
            
            // 初始化类别点击事件
            document.querySelectorAll('.category-link').forEach(link => {
                link.addEventListener('click', (e) => {
                    e.preventDefault();
                    const category = e.target.closest('.category-card').querySelector('.category-title').textContent;
                    window.location.href = `https://news.baidu.com/ns?word=${encodeURIComponent(category)}`;
                });
            });
            
            // 更新历史记录显示
            updateHistoryDisplay();
            
            // 初始化清除历史按钮
            const clearHistoryBtn = document.getElementById('clearHistoryBtn');
            if (clearHistoryBtn) {
                clearHistoryBtn.addEventListener('click', clearAllHistory);
            }
        });
    </script>
</body>
</html>
